package com.yanchangapp.adapter;

import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yanchangapp.R;
import com.yanchangapp.model.bean.OrderCommentBean;
import com.yanchangapp.widget.ExpandLayout;
import com.zxl.baselib.util.time.TimeUtil;
import com.zxl.baselib.util.ui.ResHelper;

import java.util.List;
/**
 * Created by apple on 2019-08-08.
 * description: 订单详情 -- 审批意见表 列表
 */
public class PsDetailCommentAdapter extends BaseQuickAdapter<OrderCommentBean, BaseViewHolder> {
    public PsDetailCommentAdapter(int layoutResId, @Nullable List<OrderCommentBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, OrderCommentBean orderCommentBean) {
        baseViewHolder.setText(R.id.tvUserName,
                ResHelper.getString(R.string.order_comment_user_name,orderCommentBean.getApprover()));
        // 截取...
        baseViewHolder.setText(R.id.tvTime,orderCommentBean.getTime().substring(0,10));
        baseViewHolder.setText(R.id.tvCommentName,orderCommentBean.getApprover());
        baseViewHolder.setText(R.id.tvCommentResult,orderCommentBean.getResult());
        String reason = "暂无";
        if (!TextUtils.isEmpty(orderCommentBean.getReason())){
            reason = orderCommentBean.getReason();
        }
        baseViewHolder.setText(R.id.tvCommentContent,reason);
        ImageView ivArrow = baseViewHolder.getView(R.id.ivArrow);
        ExpandLayout expandLayout = baseViewHolder.getView(R.id.expandLayout);
        expandLayout.initExpand(false,ivArrow,true);
        RelativeLayout rlHead = baseViewHolder.getView(R.id.rlHead);
        rlHead.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                    expandLayout.toggleExpand();
            }
        });
    }
}
